#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int head[N];
int ver[N << 1], W[N << 1], Next[N << 1], tot;
void add(int u, int v, int w) {
  ++tot;
  ver[tot] = v;
  W[tot] = w;
  Next[tot] = head[u];
  head[u] = tot;
}
ll mx[N], mn[N];
void dfs_dep(int u, int fu) {
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    int w = W[i];
    if (v == fu) continue;
    dfs_dep(v, u);
    mn[u] = max(mn[u], mx[v] + w);
    if (mn[u] > mx[u]) swap(mx[u], mn[u]);
  }
}
ll ans[N];
void dfs(int u, int fu, int w) {
  if (u != 1) {
    ll x = mx[u] + w == mx[fu] ? mn[fu] : mx[fu];
    x += w;
    mn[u] = max(mn[u], x);
    if (mn[u] > mx[u]) swap(mn[u], mx[u]);
  }
  ans[u] = mx[u];
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u, W[i]);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 2, n) {
    int u, v, w;
    cin >> u >> v >> w;
    add(u, v, w), add(v, u, w);
  }
  dfs_dep(1, 0);
  dfs(1, 0, 0);
  int mn = *min_element(ans + 1, ans + n + 1);
  rep(i, 1, n) if (mn == ans[i]) cout << i << endl;
  return 0;
}